//
//  SKFoodDetailTableCell.m
//  Gastrosoph
//
//  Created by 张明磊 on 12-11-6.
//
//

#import "SKFoodDetailTableCell.h"
#import "SKModel_foodDetail.h"
#import "SKModel_foodTopRank.h"
#import "SKHeaderFiles.h"
#import "SKModel_tourist.h"
#import "RNExpandingButtonBar.h"


#define SK_FOODDETAILCELL_RECT CGRectMake(0, 0, 320, 450)

#define SK_IMAGEVIEW_TITLEIMAGE_RECT CGRectMake(0, 0, 320, 20)

#define SK_LABEL_TITLELABEL_RECT CGRectMake(20, 0, 100, 20)

#define SK_IMAGEVIEW_FOODIMAGE_RECT CGRectMake(0, 20, 320, 280)

#define SK_BUTTON_OTHERFOODPHOTO_RECT CGRectMake(10, 250, 300, 38)

#define SK_BUTTON_USERHEADPORTRAIT_RECT CGRectMake(10, 310, 33, 33)

#define SK_IMAGEVIEW_USERCOMMENTBACKGROUND_RECT CGRectMake(50, 310, 258, 40)

#define SK_BUTTON_TOURISTNAME_RECT CGRectMake(60, 315, 10, 20)

#define SK_IMAGEVIEW_COMMENTLINE_RECT CGRectMake(0, 357, 320, 0.5)

#define SK_BUTTON_WANTEAT_RECT CGRectMake(20, 370, 67, 26)

#define SK_BUTTON_COMMENT_RECT CGRectMake(94, 370, 67, 26)

#define SK_BUTTON_MORE_RECT CGRectMake(260, 370, 40, 26)

#define SK_IMAGEVIEW_FOODDETAIL_RECT CGRectMake(0, 406, 320, 164)

#define SK_LABEL_RESTAURANTNAME_RECT CGRectMake(20, 416, 200, 30)

#define SK_LABEL_RESTAURANTLOCATION_RECT CGRectMake(20, 431, 180, 60)

#define SK_BUTTON_CALLPHONE_RECT CGRectMake(15, 521, 292, 41)

#define SK_BUTTON_FOODINMAP_RECT CGRectMake(230, 416, 68, 67)

#define SK_IMAGEVIEW_WANTEAT_RECT CGRectMake(9, 577, 15, 15)

#define SK_LABEL_WANTEATCOUNT_RECT CGRectMake(11, 597, 30, 15)

#define SK_IMAGEVIEW_COMMENT_RECT CGRectMake(9, 622, 15, 15)

#define SK_LABEL_COMMENTCOUNT_RECT CGRectMake(11, 642, 30, 15)

#define SK_SCROLLVIEW_OTHERUSER_RECT CGRectMake(30, 571, 220, 40)

#define SK_IMAGEVIEW_RIGHTARROW_RECT CGRectMake(290, 586, 10, 15)






typedef enum
{
    SK_expandButton_tag_love  = 0,
    
    SK_expandButton_tag_like     ,
    
    SK_expandButton_tag_general  ,
    
    SK_expandButton_tag_noMyMenu ,
    
}SK_expandButton_tag;


@implementation SKFoodDetailTableCell


@synthesize model_foodDetail = _model_foodDetail;

@synthesize integer_commentLableY = _integer_commentLableY;



- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (id)initwithModel:(SKModel_foodDetail *)_model
{
    self = [super init];
    
    if(self)
    {
        [self setFrame:SK_FOODDETAILCELL_RECT];
        
        self.model_foodDetail = _model;
        
        [self install_cell_foodImageView];
        
        [self install_cell_middleUser];
        
        [self install_cell_foodDetail];
        
        [self install_cell_expandButton];
        
        [self install_cell_likeEatView];
   
        [self install_cell_foodComment]; 
    }
    
    return self;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void)dealloc
{
    [_model_foodDetail release], _model_foodDetail = nil;
    
    [super dealloc];
}


#pragma mark - 
#pragma mark InstallCell

- (void)install_cell_foodImageView
{
    UILabel *label_title = [[UILabel alloc]initWithFrame:SK_LABEL_TITLELABEL_RECT];
    
    [label_title setTextColor:[UIColor grayColor]];
    
    [label_title setBackgroundColor:[UIColor clearColor]];
    
    [label_title setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0]];
    
    [label_title setText:[NSString stringWithFormat:@"%d人参与评分",_model_foodDetail.integer_commentPeopleCount]];
    
    [self addSubview:label_title];
    
    [label_title release];
    
    UIImageView *imageView_foodImage = [[UIImageView alloc] initWithImage:_model_foodDetail.model_foodTopRank.image_food];
    
    [imageView_foodImage setFrame:SK_IMAGEVIEW_FOODIMAGE_RECT];
    
    [self addSubview:imageView_foodImage];
    
    [imageView_foodImage release];
    
    UIButton *button_otherFoodPhoto = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_otherFoodPhoto setFrame:SK_BUTTON_OTHERFOODPHOTO_RECT];
    
    [button_otherFoodPhoto setBackgroundImage:[UIImage imageNamed:@"button_otherFoodImage.png"] forState:UIControlStateNormal];
    
    [button_otherFoodPhoto setBackgroundImage:[UIImage imageNamed:@"button_otherFoodImage_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_otherFoodPhoto.titleLabel setFont:[UIFont fontWithName:SK_TEXTFONT size:13.0]];
    
    [button_otherFoodPhoto setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
    
    NSInteger integer_tmp = [_model_foodDetail.array_otherFoodPhoto count];
    
    [button_otherFoodPhoto setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [button_otherFoodPhoto setTitle:[NSString stringWithFormat:@"  关于此美食,其他网友还分享了 %d 张照片",integer_tmp] forState:UIControlStateNormal];
    
    [self addSubview:button_otherFoodPhoto];
     
}

- (void)install_cell_middleUser
{
    UIButton *button_userHeadPortrait = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_userHeadPortrait setBackgroundImage:_model_foodDetail.model_foodTopRank.image_share_userHeadPortrait forState:UIControlStateNormal];
    
    [button_userHeadPortrait setFrame:SK_BUTTON_USERHEADPORTRAIT_RECT];
    
    [self addSubview:button_userHeadPortrait];
    
    UIImageView *imageView_userCommentBackground = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"imageView_userCommentBackground.png"]];
    
    [imageView_userCommentBackground setFrame:SK_IMAGEVIEW_USERCOMMENTBACKGROUND_RECT];
    
    [self addSubview:imageView_userCommentBackground];
    
    [imageView_userCommentBackground release];
    
    UIButton *button_tourist = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_tourist setFrame:SK_BUTTON_TOURISTNAME_RECT];
    
    SKModel_tourist *tourist_tmp = [_model_foodDetail.model_foodTopRank.array_touristArray objectAtIndex:0];
    
    [button_tourist.titleLabel setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
    
    button_tourist.titleLabel.numberOfLines = 0;
    
    CGSize button_size = [tourist_tmp.string_touristName sizeWithFont:[UIFont fontWithName:SK_TEXTFONT size:12.0] constrainedToSize:CGSizeMake(115.0f, 200.0f) lineBreakMode:UILineBreakModeWordWrap];
    
    CGRect button_rect = button_tourist.frame;
    
    button_rect.size = button_size;
    
    [button_tourist setFrame:button_rect];
    
    [button_tourist setTitle:tourist_tmp.string_touristName forState:UIControlStateNormal];
    
    [button_tourist setTitleColor:[UIColor brownColor] forState:UIControlStateNormal];
    
    [button_tourist setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
    
    [self addSubview:button_tourist];
    
    UILabel *label_tourist = [[UILabel alloc] initWithFrame:CGRectMake(button_tourist.frame.origin.x + button_tourist.frame.size.width, button_tourist.frame.origin.y, 200, 20)];
    
    [label_tourist setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
    
    CGSize labelSize = [tourist_tmp.string_touristComment sizeWithFont:[UIFont fontWithName:SK_TEXTFONT size:12.0] constrainedToSize:CGSizeMake(200.0f, 200.0f) lineBreakMode:UILineBreakModeWordWrap];
    
    label_tourist.numberOfLines = 0;
    
    CGRect labelRect = label_tourist.frame;
    
    labelRect.size = labelSize;
    
    [label_tourist setFrame:labelRect];
    
    [label_tourist setBackgroundColor:[UIColor clearColor]];
    
    [label_tourist setTextColor:[UIColor grayColor]];
    
    [label_tourist setText:tourist_tmp.string_touristComment];
    
    [self addSubview:label_tourist];
    
    [label_tourist release];
    
    UIImageView *image_commentLine = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imageView_commentLine.png"]];
    
    [image_commentLine setFrame:SK_IMAGEVIEW_COMMENTLINE_RECT];
    
    [image_commentLine setAlpha:0.6f];
    
    [self addSubview:image_commentLine];
    
    [image_commentLine release];
    
    UIButton *button_wantEat = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_wantEat setFrame:SK_BUTTON_WANTEAT_RECT];
    
    [button_wantEat setBackgroundImage:[UIImage imageNamed:@"cell_foodTop_button_wantEat.png"] forState:UIControlStateNormal];
    
    [button_wantEat setBackgroundImage:[UIImage imageNamed:@"cell_foodTop_button_wantEat_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_wantEat addTarget:self action:@selector(didClickButton_wantEat) forControlEvents:UIControlEventTouchUpInside];
    
    [button_wantEat.titleLabel setFont:[UIFont fontWithName:SK_TEXTFONT size:15.0]];
    
    [button_wantEat setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    
    [button_wantEat setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
    
    [button_wantEat setTitle:@"想吃 " forState:UIControlStateNormal];
    
    [self addSubview:button_wantEat];
    
    UIButton *button_comment = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_comment setFrame:SK_BUTTON_COMMENT_RECT];
    
    [button_comment setBackgroundImage:[UIImage imageNamed:@"cell_foodTop_button_comment.png"] forState:UIControlStateNormal];
    
    [button_comment setBackgroundImage:[UIImage imageNamed:@"cell_foodTop_button_comment_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_comment addTarget:self action:@selector(didClickButton_comment) forControlEvents:UIControlEventTouchUpInside];
    
    [button_comment.titleLabel setFont:[UIFont fontWithName:SK_TEXTFONT size:15.0]];
    
    [button_comment setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    
    [button_comment setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
    
    [button_comment setTitle:@"评论 " forState:UIControlStateNormal];
    
    [self addSubview:button_comment];
    
    UIButton *button_more = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_more setFrame:SK_BUTTON_MORE_RECT];
    
    [button_more setBackgroundImage:[UIImage imageNamed:@"cell_foodTop_button_more.png"] forState:UIControlStateNormal];
    
    [button_more setBackgroundImage:[UIImage imageNamed:@"cell_foodTop_button_more_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_more addTarget:self action:@selector(didClickButton_more) forControlEvents:UIControlEventTouchUpInside];
    
    [self addSubview:button_more];
}

- (void)install_cell_foodDetail
{
    UIImageView *imageView_foodDetail = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imageView_detailBackground.png"]];
    
    [imageView_foodDetail setFrame:SK_IMAGEVIEW_FOODDETAIL_RECT];
    
    [self addSubview:imageView_foodDetail];
    
    [imageView_foodDetail release];
    
    UILabel *label_restaurant = [[UILabel alloc] initWithFrame:SK_LABEL_RESTAURANTNAME_RECT];
    
    [label_restaurant setBackgroundColor:[UIColor clearColor]];
    
    [label_restaurant setFont:[UIFont fontWithName:SK_TEXTFONT size:17.0f]];
    
    [label_restaurant setTextColor:[UIColor blackColor]];
    
    [label_restaurant setText:_model_foodDetail.model_foodTopRank.string_restaurantName];
    
    [self addSubview:label_restaurant];
    
    [label_restaurant release];
    
    UILabel *label_retaurantLocation = [[UILabel alloc] initWithFrame:SK_LABEL_RESTAURANTLOCATION_RECT];
    
    [label_retaurantLocation setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
    
    [label_retaurantLocation setTextColor:[UIColor blackColor]];
    
    [label_retaurantLocation setBackgroundColor:[UIColor clearColor]];
    
    [label_retaurantLocation setText:_model_foodDetail.string_restaurantLocation];
    
    label_retaurantLocation.numberOfLines = 0;
    
    [self addSubview:label_retaurantLocation];
    
    [label_retaurantLocation release];
    
    UILabel *label_costHead = [[UILabel alloc] initWithFrame:CGRectMake(label_retaurantLocation.frame.origin.x, label_retaurantLocation.frame.origin.y + label_retaurantLocation.frame.size.height, 50, 30)];
    
    [label_costHead setTextColor:[UIColor blackColor]];
    
    [label_costHead setBackgroundColor:[UIColor clearColor]];
    
    [label_costHead setFont:[UIFont fontWithName:SK_TEXTFONT size:14.0f]];
    
    [label_costHead setText:@"人均 :"];
    
    [self addSubview:label_costHead];
    
    [label_costHead release];
    
    UILabel *label_cost = [[UILabel alloc] initWithFrame:CGRectMake(label_costHead.frame.origin.x + label_costHead.frame.size.width, label_costHead.frame.origin.y, 60, 30)];
    
    [label_cost setTextColor:[UIColor brownColor]];
    
    [label_cost setBackgroundColor:[UIColor clearColor]];
    
    [label_cost setFont:[UIFont fontWithName:SK_TEXTFONT size:14.0f]];
    
    [label_cost setText:_model_foodDetail.string_foodCost];
    
    [self addSubview:label_cost];
    
    [label_cost release];

    UILabel *label_styleHead = [[UILabel alloc] initWithFrame:CGRectMake(label_cost.frame.origin.x + label_cost.frame.size.width, label_cost.frame.origin.y, 50, 30)];
    
    [label_styleHead setTextColor:[UIColor blackColor]];
    
    [label_styleHead setBackgroundColor:[UIColor clearColor]];
    
    [label_styleHead setFont:[UIFont fontWithName:SK_TEXTFONT size:14.0f]];
    
    [label_styleHead setText:@"菜系 :"];
    
    [self addSubview:label_styleHead];
    
    [label_styleHead release];
    
    UILabel *label_style = [[UILabel alloc] initWithFrame:CGRectMake(label_styleHead.frame.origin.x + label_styleHead.frame.size.width, label_styleHead.frame.origin.y, 60, 30)];
    
    [label_style setTextColor:[UIColor brownColor]];
    
    [label_style setBackgroundColor:[UIColor clearColor]];
    
    [label_style setFont:[UIFont fontWithName:SK_TEXTFONT size:14.0f]];
    
    [label_style setText:_model_foodDetail.string_styleOfCooking];
    
    [self addSubview:label_style];
    
    [label_style release];
    
    UIButton *button_foodInMap = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_foodInMap setFrame:SK_BUTTON_FOODINMAP_RECT];
    
    [button_foodInMap addTarget:self action:@selector(didClickButton_foodInMap) forControlEvents:UIControlEventTouchUpInside];
    
    [button_foodInMap setBackgroundImage:[UIImage imageNamed:@"button_foodInMap.png"] forState:UIControlStateNormal];
    
    [self addSubview:button_foodInMap];
    
    UIButton *button_callPhone = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_callPhone setFrame:SK_BUTTON_CALLPHONE_RECT];
    
    [button_callPhone addTarget:self action:@selector(didClickButton_callPhone) forControlEvents:UIControlEventTouchUpInside];
    
    [button_callPhone setBackgroundImage:[UIImage imageNamed:@"button_phone.png"] forState:UIControlStateNormal];
    
    [button_callPhone setBackgroundImage:[UIImage imageNamed:@"button_phone_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_callPhone.titleLabel setFont:[UIFont fontWithName:SK_TEXTFONT size:16.0f]];
    
    [button_callPhone setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
    
    [button_callPhone setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [button_callPhone setTitle:[NSString stringWithFormat:@"  %@",_model_foodDetail.string_restaurantPhone] forState:UIControlStateNormal];
    
    [self addSubview:button_callPhone];
}



- (void)install_cell_expandButton
{
    CGRect expandButtonFrame = CGRectMake(0, 0, 71.5, 47);
    
    CGPoint center = CGPointMake(230, 10);
    
    UIButton *button_love = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_love setImage:[UIImage imageNamed:@"expandButton_love.png"] forState:UIControlStateNormal];
    
    [button_love setImage:[UIImage imageNamed:@"expandButton_love_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_love setFrame:expandButtonFrame];
    
    [button_love setTag:SK_expandButton_tag_love];
    
    [button_love addTarget:self action:@selector(didClickExpandButton:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *button_like = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_like setImage:[UIImage imageNamed:@"expandButton_like.png"] forState:UIControlStateNormal];
    
    [button_like setImage:[UIImage imageNamed:@"expandButton_like_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_like setFrame:expandButtonFrame];
    
    [button_like setTag:SK_expandButton_tag_like];
    
    [button_like addTarget:self action:@selector(didClickExpandButton:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *button_general = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_general setImage:[UIImage imageNamed:@"expandButton_general.png"] forState:UIControlStateNormal];
    
    [button_general setImage:[UIImage imageNamed:@"expandButton_general_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_general setFrame:expandButtonFrame];
    
    [button_general setTag:SK_expandButton_tag_general];
    
    [button_general addTarget:self action:@selector(didClickExpandButton:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *button_noMyMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button_noMyMenu setFrame:expandButtonFrame];
    
    [button_noMyMenu setImage:[UIImage imageNamed:@"expandButton_noMyMenu.png"] forState:UIControlStateNormal];
    
    [button_noMyMenu setImage:[UIImage imageNamed:@"expandButton_noMyMenu_pressed.png"] forState:UIControlStateHighlighted];
    
    [button_noMyMenu setTag:SK_expandButton_tag_noMyMenu];
    
    [button_noMyMenu addTarget:self action:@selector(didClickExpandButton:) forControlEvents:UIControlEventTouchUpInside];
    
    NSArray *buttons = [NSArray arrayWithObjects:button_noMyMenu,button_general,button_like,button_love,nil];
    
    switch (_model_foodDetail.model_foodTopRank.integer_foodRate)
    {
        case 0:
        {
            buttonBar = [[RNExpandingButtonBar alloc]
                               initWithImage:[UIImage imageNamed:@"expandButton_top_love.png"] selectedImage:[UIImage imageNamed:@"expandButton_top_love.png"] toggledImage:[UIImage imageNamed:@"expandButton_love.png"] toggledSelectedImage:[UIImage imageNamed:@"expandButton_love_pressed.png"] buttons:buttons center:center];
            
            [self addSubview:buttonBar];
            
            [buttonBar release];
            
            break;
        }
            
        case 1:
        {
            buttonBar = [[RNExpandingButtonBar alloc]
                               initWithImage:[UIImage imageNamed:@"expandButton_top_like.png"] selectedImage:[UIImage imageNamed:@"expandButton_top_like.png"] toggledImage:[UIImage imageNamed:@"expandButton_love.png"] toggledSelectedImage:[UIImage imageNamed:@"expandButton_love_pressed.png"] buttons:buttons center:center];
            
            [self addSubview:buttonBar];
            
            [buttonBar release];
            
            break;
        }
            
        case 2:
        {
            buttonBar = [[RNExpandingButtonBar alloc]
                               initWithImage:[UIImage imageNamed:@"expandButton_top_general.png"] selectedImage:[UIImage imageNamed:@"expandButton_top_general.png"] toggledImage:[UIImage imageNamed:@"expandButton_love.png"] toggledSelectedImage:[UIImage imageNamed:@"expandButton_love_pressed.png"] buttons:buttons center:center] ;
            
            
            [self addSubview:buttonBar];
            
            [buttonBar release];
            
            break;
        }
            
        default:
            break;
    }
    
}

- (void)install_cell_likeEatView
{
    UIImageView *image_likeEat = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imageView_wantEat.png"]];
    
    [image_likeEat setFrame:SK_IMAGEVIEW_WANTEAT_RECT];
    
    [self addSubview:image_likeEat];
    
    [image_likeEat release];
    
    UILabel *label_likeEatCount = [[UILabel alloc] initWithFrame:SK_LABEL_WANTEATCOUNT_RECT];
    
    [label_likeEatCount setTextColor:[UIColor grayColor]];
    
    [label_likeEatCount setBackgroundColor:[UIColor clearColor]];
    
    [label_likeEatCount setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
    
    [label_likeEatCount setText:[NSString stringWithFormat:@"%d",_model_foodDetail.model_foodTopRank.integer_wantEatCount]];
    
    [self addSubview:label_likeEatCount];
    
    [label_likeEatCount release];
    
    UIImageView *image_comment = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imageView_comment.png"]];
    
    [image_comment setFrame:SK_IMAGEVIEW_COMMENT_RECT];
    
    [self addSubview:image_comment];
    
    [image_comment release];
    
    UILabel *label_commentCount = [[UILabel alloc] initWithFrame:SK_LABEL_COMMENTCOUNT_RECT];
    
    [label_commentCount setTextColor:[UIColor grayColor]];
    
    [label_commentCount setBackgroundColor:[UIColor clearColor]];
    
    [label_commentCount setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
    
    [label_commentCount setText:[NSString stringWithFormat:@"%d",_model_foodDetail.model_foodTopRank.integer_commentCount]];
    
    [self addSubview:label_commentCount];
    
    [label_commentCount release];
    
    UIScrollView *scrollView_otherUser = [[UIScrollView alloc] initWithFrame:SK_SCROLLVIEW_OTHERUSER_RECT];
    
    [scrollView_otherUser setBackgroundColor:[UIColor clearColor]];
    
    for(int i = 0; i < _model_foodDetail.model_foodTopRank.integer_wantEatCount; i++)
    {
        UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
        
        [button setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"test_user_%d.png", i + 1]] forState:UIControlStateNormal];
        
        button.frame = CGRectMake(10 + i*(33 + 10), 5.0f, 33.0f, 33.0f);
        
        button.tag = i;
        
		[scrollView_otherUser addSubview:button];
	}
    
	[scrollView_otherUser setContentSize:CGSizeMake(10 + 10 + _model_foodDetail.model_foodTopRank.integer_wantEatCount*(33+10), 40.0)];
    
    [self addSubview:scrollView_otherUser];
    
    [scrollView_otherUser release];
    
    if(_model_foodDetail.model_foodTopRank.integer_wantEatCount > 5)
    {
        UIImageView *imageView_rightArrow = [[UIImageView alloc] initWithFrame:SK_IMAGEVIEW_RIGHTARROW_RECT];
        
        [imageView_rightArrow setImage:[UIImage     imageNamed:@"cell_imageView_rightArrow.png"]];
        
        [self addSubview:imageView_rightArrow];
        
        [imageView_rightArrow release];
    }
}


- (void)install_cell_foodComment
{
    if(_model_foodDetail.model_foodTopRank.integer_commentCount < 4)
    {
        for (int i = 0; i < _model_foodDetail.model_foodTopRank.integer_commentCount;i++)
        {
            UIButton *button_tourist = [UIButton buttonWithType:UIButtonTypeCustom];
            
            [button_tourist setFrame:CGRectMake(40, 350 + self.integer_commentLableY, 10, 20)];
            
            [button_tourist setTag:i];
            
            [button_tourist addTarget:self action:@selector(didClickButton_touristName:) forControlEvents:UIControlEventTouchUpInside];
            
            SKModel_tourist *tourist_tmp = [_model_foodDetail.model_foodTopRank.array_touristArray objectAtIndex:i];
            
            [button_tourist.titleLabel setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
            
            button_tourist.titleLabel.numberOfLines = 0;
            
            CGSize button_size = [tourist_tmp.string_touristName sizeWithFont:[UIFont fontWithName:SK_TEXTFONT size:12.0] constrainedToSize:CGSizeMake(115.0f, 200.0f) lineBreakMode:UILineBreakModeWordWrap];
            
            CGRect button_rect = button_tourist.frame;
            
            button_rect.size = button_size;
            
            [button_tourist setFrame:button_rect];
            
            [button_tourist setTitle:tourist_tmp.string_touristName forState:UIControlStateNormal];
            
            [button_tourist setTitleColor:[UIColor brownColor] forState:UIControlStateNormal];
            
            [button_tourist setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
            
            [self addSubview:button_tourist];
            
            UILabel *label_tourist = [[UILabel alloc] initWithFrame:CGRectMake(button_tourist.frame.origin.x + button_tourist.frame.size.width, button_tourist.frame.origin.y, 200, 20)];
            
            [label_tourist setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
            
            CGSize labelSize = [tourist_tmp.string_touristComment sizeWithFont:[UIFont fontWithName:SK_TEXTFONT size:12.0] constrainedToSize:CGSizeMake(200.0f, 200.0f) lineBreakMode:UILineBreakModeWordWrap];
            
            label_tourist.numberOfLines = 0;
            
            CGRect labelRect = label_tourist.frame;
            
            labelRect.size = labelSize;
            
            [label_tourist setFrame:labelRect];
            
            [label_tourist setBackgroundColor:[UIColor clearColor]];
            
            [label_tourist setTextColor:[UIColor grayColor]];
            
            [label_tourist setText:tourist_tmp.string_touristComment];
            
            [self addSubview:label_tourist];
            
            [label_tourist release];
            
            if(label_tourist.frame.size.height >= button_tourist.frame.size.height)
            {
                self.integer_commentLableY += label_tourist.frame.size.height + 7;
            }
            
            else
            {
                self.integer_commentLableY += button_tourist.frame.size.height + 7;
            }
        }
    }
    
    else
    {
        for (int i = 0; i < 3;i++)
        {
            UIButton *button_tourist = [UIButton buttonWithType:UIButtonTypeCustom];
            
            [button_tourist setFrame:CGRectMake(40, 618 + self.integer_commentLableY, 10, 20)];
            
            [button_tourist setTag:i];
            
            [button_tourist addTarget:self action:@selector(didClickButton_touristName:) forControlEvents:UIControlEventTouchUpInside];
            
            SKModel_tourist *tourist_tmp = [_model_foodDetail.model_foodTopRank.array_touristArray objectAtIndex:i];
            
            [button_tourist.titleLabel setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
            
            button_tourist.titleLabel.numberOfLines = 0;
            
            CGSize button_size = [tourist_tmp.string_touristName sizeWithFont:[UIFont fontWithName:SK_TEXTFONT size:12.0] constrainedToSize:CGSizeMake(115.0f, 200.0f) lineBreakMode:UILineBreakModeWordWrap];
            
            CGRect button_rect = button_tourist.frame;
            
            button_rect.size = button_size;
            
            [button_tourist setFrame:button_rect];
            
            [button_tourist setTitle:tourist_tmp.string_touristName forState:UIControlStateNormal];
            
            [button_tourist setTitleColor:[UIColor brownColor] forState:UIControlStateNormal];
            
            [button_tourist setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
            
            [self addSubview:button_tourist];
            
            UILabel *label_tourist = [[UILabel alloc] initWithFrame:CGRectMake(button_tourist.frame.origin.x + button_tourist.frame.size.width, button_tourist.frame.origin.y, 200, 20)];
            
            [label_tourist setFont:[UIFont fontWithName:SK_TEXTFONT size:12.0f]];
            
            CGSize labelSize = [tourist_tmp.string_touristComment sizeWithFont:[UIFont fontWithName:SK_TEXTFONT size:12.0] constrainedToSize:CGSizeMake(200.0f, 200.0f) lineBreakMode:UILineBreakModeWordWrap];
            
            label_tourist.numberOfLines = 0;
            
            CGRect labelRect = label_tourist.frame;
            
            labelRect.size = labelSize;
            
            [label_tourist setFrame:labelRect];
            
            [label_tourist setBackgroundColor:[UIColor clearColor]];
            
            [label_tourist setTextColor:[UIColor grayColor]];
            
            [label_tourist setText:tourist_tmp.string_touristComment];
            
            [self addSubview:label_tourist];
            
            [label_tourist release];
            
            if(label_tourist.frame.size.height >= button_tourist.frame.size.height)
            {
                self.integer_commentLableY += label_tourist.frame.size.height + 7;
            }
            
            else
            {
                self.integer_commentLableY += button_tourist.frame.size.height + 7;
            }
        }
        
        UIButton *button_showAllComment = [UIButton buttonWithType:UIButtonTypeCustom];
        
        [button_showAllComment setFrame:CGRectMake(20, 618 + self.integer_commentLableY, 150, 20)];
        
        [button_showAllComment addTarget:self action:@selector(didClickButton_showAlltourist:) forControlEvents:UIControlEventTouchUpInside];
        
        [button_showAllComment setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [button_showAllComment setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
        
        [button_showAllComment.titleLabel setFont:[UIFont fontWithName:SK_TEXTFONT size:14.0f]];
        
        [button_showAllComment setTitle:[NSString stringWithFormat:@"查看全部%d条评论",_model_foodDetail.model_foodTopRank.integer_commentCount] forState:UIControlStateNormal];
        
        [self addSubview:button_showAllComment];
    }
    
    if(self.integer_commentLableY)
    {
    
        UIImageView *imageView_youLikeView = [[UIImageView alloc] initWithFrame:CGRectMake(0,648 + self.integer_commentLableY , 320, 193)];
    
        [imageView_youLikeView setImage:[UIImage imageNamed:@"imageView_detailBackground.png"]];
    
        [self addSubview:imageView_youLikeView];
    
        [imageView_youLikeView release];
        
        UILabel *label_youLike = [[UILabel alloc] initWithFrame:CGRectMake(20, imageView_youLikeView.frame.origin.y + 5, 100, 30)];
        
        [label_youLike setBackgroundColor:[UIColor clearColor]];
        
        [label_youLike setFont:[UIFont fontWithName:SK_TEXTFONT size:16.0f]];
        
        [label_youLike setTextColor:[UIColor blackColor]];
        
        [label_youLike setText:@"猜你喜欢"];
        
        [self addSubview:label_youLike];
        
        [label_youLike release];
        
        UIScrollView *scrollView_otherUser = [[UIScrollView alloc] initWithFrame:CGRectMake(2, label_youLike.frame.origin.y + label_youLike.frame.size.height, 290, 80)];
        
        [scrollView_otherUser setBackgroundColor:[UIColor clearColor]];
        
        for(int i = 0; i < [_model_foodDetail.array_youLikeFoodPhoto count]; i++)
        {
            UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
            
            [button setBackgroundImage:[_model_foodDetail.array_youLikeFoodPhoto objectAtIndex:i] forState:UIControlStateNormal];
            
            button.frame = CGRectMake(10 + i*(75 + 10), 5.0f, 75.0f, 75.0f);
            
            button.tag = i;
            
            [scrollView_otherUser addSubview:button];
        }
        
        [scrollView_otherUser setContentSize:CGSizeMake(10 + 10 + [_model_foodDetail.array_youLikeFoodPhoto count]*(75 + 10), 40.0)];
        
        [self addSubview:scrollView_otherUser];
        
        [scrollView_otherUser release];
        
        if([_model_foodDetail.array_youLikeFoodPhoto count] > 3)
        {
            UIImageView *imageView_rightArrow = [[UIImageView alloc] initWithFrame:CGRectMake(scrollView_otherUser.frame.origin.x + scrollView_otherUser.frame.size.width + 7, scrollView_otherUser.frame.origin.y + 35, 10, 15)];
            
            [imageView_rightArrow setImage:[UIImage     imageNamed:@"cell_imageView_rightArrow.png"]];
            
            [self addSubview:imageView_rightArrow];
            
            [imageView_rightArrow release];
        }
        
        UIImageView *imageView_logo = [[UIImageView alloc] initWithFrame:CGRectMake(138, scrollView_otherUser.frame.origin.y + scrollView_otherUser.frame.size.height + 15, 50, 45)];
        
        [imageView_logo setImage:[UIImage imageNamed:@"imageView_foodDetail_logo.png"]];
        
        [self addSubview:imageView_logo];
        
        [imageView_logo release];
    }
    else
    {
        UIImageView *imageView_youLikeView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 668, 320, 193)];
        
        [imageView_youLikeView setImage:[UIImage imageNamed:@"imageView_detailBackground.png"]];
        
        [self addSubview:imageView_youLikeView];
        
        [imageView_youLikeView release];
        
        UILabel *label_youLike = [[UILabel alloc] initWithFrame:CGRectMake(20, imageView_youLikeView.frame.origin.y + 5, 100, 30)];
        
        [label_youLike setBackgroundColor:[UIColor clearColor]];
        
        [label_youLike setFont:[UIFont fontWithName:SK_TEXTFONT size:16.0f]];
        
        [label_youLike setTextColor:[UIColor blackColor]];
        
        [label_youLike setText:@"猜你喜欢"];
        
        [self addSubview:label_youLike];
        
        [label_youLike release];
        
        UIScrollView *scrollView_otherUser = [[UIScrollView alloc] initWithFrame:CGRectMake(2, label_youLike.frame.origin.y + label_youLike.frame.size.height, 290, 80)];
        
        [scrollView_otherUser setBackgroundColor:[UIColor clearColor]];
        
        for(int i = 0; i < [_model_foodDetail.array_youLikeFoodPhoto count]; i++)
        {
            UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
            
            [button setBackgroundImage:[_model_foodDetail.array_youLikeFoodPhoto objectAtIndex:i] forState:UIControlStateNormal];
            
            button.frame = CGRectMake(10 + i*(75 + 10), 5.0f, 75.0f, 75.0f);
            
            button.tag = i;
            
            [scrollView_otherUser addSubview:button];
        }
        
        [scrollView_otherUser setContentSize:CGSizeMake(10 + 10 + [_model_foodDetail.array_youLikeFoodPhoto count]*(75 + 10), 40.0)];
        
        [self addSubview:scrollView_otherUser];
        
        [scrollView_otherUser release];
        
        if([_model_foodDetail.array_youLikeFoodPhoto count] > 3)
        {
            UIImageView *imageView_rightArrow = [[UIImageView alloc] initWithFrame:CGRectMake(scrollView_otherUser.frame.origin.x + scrollView_otherUser.frame.size.width + 7, scrollView_otherUser.frame.origin.y + 35, 10, 15)];
            
            [imageView_rightArrow setImage:[UIImage     imageNamed:@"cell_imageView_rightArrow.png"]];
            
            [self addSubview:imageView_rightArrow];
            
            [imageView_rightArrow release];
        }
        
        UIImageView *imageView_logo = [[UIImageView alloc] initWithFrame:CGRectMake(138, scrollView_otherUser.frame.origin.y + scrollView_otherUser.frame.size.height + 15, 50, 45)];
        
        [imageView_logo setImage:[UIImage imageNamed:@"imageView_foodDetail_logo.png"]];
    
        [self addSubview:imageView_logo];
        
        [imageView_logo release];
    }
}




#pragma mark -
#pragma mark DidClickCellButton

- (void)didClickButton_wantEat
{
    
}

- (void)didClickButton_comment
{
    
}

- (void)didClickButton_more
{
    
}

- (void)didClickButton_callPhone
{
    
}

- (void)didClickButton_foodInMap
{
    
}


#pragma mark -
#pragma mark InstallTouristNameButton

- (void)didClickButton_touristName:(id)sender
{
    
}

- (void)didClickButton_showAlltourist:(id)sender
{

}





#pragma mark -
#pragma mark InstallExpandButton

- (void)didClickExpandButton:(id)sender
{
    UIButton *expandButton = (UIButton *)sender;
    
    switch (expandButton.tag)
    {
        case SK_expandButton_tag_love:
        {
            [buttonBar hideButtonsAnimated:YES];
            
            break;
        }
            
        case SK_expandButton_tag_like:
        {
            [buttonBar hideButtonsAnimated:YES];
            
            break;
        }
            
        case SK_expandButton_tag_general:
        {
            [buttonBar hideButtonsAnimated:YES];
            
            break;
        }
            
        case SK_expandButton_tag_noMyMenu:
        {
            [buttonBar hideButtonsAnimated:YES];
            
            break;
        }
            
        default:
            break;
    }
}





@end
